<template>
  <a-card :bordered="false">
    <a-tabs default-active-key="1" tab-position="top">
      <a-tab-pane key="1" tab="历史文档">
        <!-- 搜索条件 -->
<!--        <div class="table-page-search-wrapper">-->
<!--          <a-form layout="inline">-->
<!--            <a-row :gutter="48">-->
<!--              <a-col :md="8" :sm="24">-->
<!--                <a-form-item label="报表日期">-->
<!--                  <a-range-picker  v-model="timeValue"/>-->
<!--                </a-form-item>-->
<!--              </a-col>-->

<!--              <a-col :md="8" :sm="24">-->
<!--            <span class="table-page-search-submitButtons" >-->
<!--              <a-button type="primary" icon="search" >查询</a-button>-->
<!--              <a-button type="primary" style="margin-left: 8px"  icon="reload" >重置</a-button>-->
<!--            </span>-->
<!--              </a-col>-->
<!--            </a-row>-->
<!--          </a-form>-->
<!--        </div>-->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
          <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
        </div>
        <a-spin :spinning='loading' tip=" 正在下载数据，请耐心等待">
          <a-table
            :rowKey="record => record.id"
            ref="table"
            size="middle"
            bordered
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
          >
            <span slot='action' slot-scope='text, record,index'>
                  <span v-if="record.status==1">完成</span>
                  <span v-else>未完成</span>
            </span>
          </a-table>
        </a-spin>
      </a-tab-pane>


      <a-tab-pane key="2" tab="去向单位模板管理">

        <EpaStatisticsCategoryTemplate></EpaStatisticsCategoryTemplate>

      </a-tab-pane>
      <a-tab-pane key="3" tab="关键字模板管理">

        <EpaStatisticsKeywordTemplate></EpaStatisticsKeywordTemplate>

      </a-tab-pane>
    </a-tabs>
  </a-card>
</template>

<script>
import EpaStatisticsCategoryTemplate from '@views/epa/epa-statistics/EpaStatisticsCategoryTemplate'
import EpaStatisticsKeywordTemplate from '@views/epa/epa-statistics/EpaStatisticsKeywordTemplate'
import EpaSortService from '@/myService/EpaSortService'
export default {
  name: 'epaStatisticsHome',
  components:{
    EpaStatisticsCategoryTemplate,
    EpaStatisticsKeywordTemplate,
  },
  data() {
    return {
      loading: true,
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      timeValue: undefined,
      dataSource: [],
      queryParam: {
        startDate: '',
        endDate: ''
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: (text, row, index) =>
            <span>{this.ipagination.pageSize * (this.ipagination.current - 1) + index + 1}</span>
        },
        {
          title: '开始时间',
          align: "center",
          dataIndex: 'startDate'
        },
        {
          title: '结束时间',
          align: "center",
          dataIndex: 'endDate'
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      downLoading: false
    }
  },
  created() {
    this.getSortWeek()
  },
  methods:{
    handleAdd(){
      this.$router.push("/epa/epa-statistics-add")
    },
    getSortWeek(){
      this.dataSource=[]
      this.ipagination.total=0
      this.queryParam.pageSize=this.ipagination.pageSize
      this.queryParam.currentPage=this.ipagination.current
      EpaSortService.selectSortWeek(this.queryParam).then((res)=>{
        console.log(res)
        this.dataSource=res.result.records
        this.ipagination.total=res.result.total
      }).finally(
        ()=>{
          this.loading=false
        }
      )
    },
    handleTableChange(pagination){
      console.log(pagination)
      this.ipagination.current=pagination.current
      this.ipagination.pageSize=pagination.pageSize
      console.log(this.ipagination)
      this.getDataSourceList();
    },
  }
}
</script>

<style scoped>

</style>